<%@ page import="java.util.ArrayList" %>
<%@ page import="com.bean.Article" %>
<%@ page import="com.bean.Articletype" %>
<%@ page import="com.Dao.ArticleTypeDao" %>
<%@ page import="java.util.List" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%--<%@ page import="java.util.ArrayList" %>--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>说说博客-所有文章</title>
    <link type="text/css" rel="stylesheet" href="${pageContext.request.contextPath}/front/css/main.css">
    <style>
        .right a{
            text-decoration: none;
        }
    </style>
</head>
<%--<body background="${pageContext.request.contextPath}/front/images/sea.jpg">--%>
<body>
<%--头部--%>
<%@include file="../view/FrontTop.jsp"%>

<%--左边--%>
<%@include file="../view/FrontLeft.jsp"%>
<div class="right">
    <table class="rightcontent">
        <td width="548" align="center" valign="top">
            <table width="100%" height="55" border="0" cellsapcing="0" cellpadding="0">
                <tr align="center" style="padding-bottom:10px">
                    <td style="text-anchor:start;">
                            <%
                        ArticleTypeDao articleTypeDao=new ArticleTypeDao();
                        List<Articletype> allType=articleTypeDao.getAllType();
                        if(allType==null||allType.size()==0){
                    %>
                    <td align="center"><li>没有文章类别可显示！</li></td>
                    <%
                    }
                    else{
                        for(int i=0;i<allType.size();i++){
                            Articletype single=(Articletype)allType.get(i);
                    %>
                    <td>
                        <a href="/Article?action=select&typeName=<%=single.getTypeName() %>"><%=single.getTypeName() %></a>
                    </td>
                    <%
                            }
                        }
                    %>
                    </td>
                </tr>
            </table>
            <table width="95%" border="0" cellsapcing="0" cellpadding="0">
                <%
                    List articleList= (List) request.getAttribute("articleList");
                    if(articleList.size()==0)
                        out.print("<tr height='60'><td align='center'>选择的文章类别中没有任何文章！</td></tr>");
                    else {
                        Article articleSingle = (Article) articleList.get(0);
                        int books=articleList.size();
                        String typeName=articleSingle.getTypename();
                        out.print("<tr height='60'><td align='center'>【"+typeName+" 共 "+books+" 篇】</td></tr>");%>
                <tr height="2"><td background="/front/images/line.jpg" colspan="2"></td></tr>
                <%
                    int i=0;
                    while(i<articleList.size()){
                        articleSingle=(Article)articleList.get(i);
                %>
                <tr height="30">
                    <td colspan="2">
                        ▲
                        <a href="/Article?action=read&id=<%=articleSingle.getId() %>"><%=articleSingle.getTitle() %></a>
                        [<%=articleSingle.getOrigin()%>]
                    </td>
                </tr>
                <tr height="60"><td colspan="2" valign="top">
                    <%=articleSingle.getContent(100) %>
                </td></tr>
                <tr height="30">
                    <td style="text-indent:20px" colspan="2">
                        <a href="/Article?action=read&id=<%=articleSingle.getId() %>">阅读全文</a>
                    </td>
                </tr>
                <tr>
                    <td align="right" colspan="2">
                        发表时间：<%=articleSingle.getPubtime()%> |
                        评论：<%=articleSingle.getRemark() %> |
                        阅读：<%=articleSingle.getCount() %> 次
                    </td>
                </tr>
                <tr height="2"><td background="/front/images/line.jpg" colspan="2"></td></tr>
                <%
                            i++;
                        }
                    }
                %>
                <tr><td>
            </table>
        </td>
        </tr>
    </table>
</div>


<%--底部--%>
<%@include file="../view/FrontEnd.jsp"%>
</body>
</html>
